(function(){

    app.section.onReady = function (params) {
        $('#_1_txP').remove();
    };
    
    app.section.onLoad = function () {
    
        var keywordS = $app.getSession('keyword');
        if($app.judgeData(keywordS)){
            $('#_3_topText').val(keywordS);
            $app.removeSession('keyword');//删除本地存储
        }
    
    
    
        //一般上拉、下拉刷新只选择一种使用，下面同时出现两种只为方便演示
        var iScroll3 = ui.IScroll.init("#_3_pullrefresh", {
            scrollBar: true,
            enablePullDown: false,
            enablePullUp: true,
            pullUpAction: pullUpActionDemo3
        });
    
        iScroll3.destroyMe()
        
        var pageC=0;
        
        function accessList3(){//上拉加载，总函数
            $app.loading();
            pageC+=1;
            var keyword=$app.inputVal('#_3_topText');
            var status=4;
            var orderBy = 4
            
            //获取列表
            $ajax.accessList( status, pageC, keyword, orderBy, function(res){
                $app.iScrollDo(res,iScroll3,function(resData){
                    var htmlY='';
    
                    resData.forEach(function(val,i){
                        
                        // var statusT=$app.systemStatus(val.status);
                        // var statusC=$app.systemStatusColor(val.status);
                        const { label, color } = $app.VISIT_STATUS(val.status);
                        
    
                        htmlY+='<li class="paddingLiB table-view-cell" data-id=\"'+val.id+'\">\
                            <div class="navigate-right">\
                                <div class="row-fluid">\
                                    <div class="span10">\
                                        <div class="row-fluid  lineH30">\
                                            <div class="span5 f_26 c333"><i class="icon-user f_18 cCCC stringBug1 paddingR10"></i>'+val.name+'</div>\
                                            <div class="span7 f_22 c666 "><i class="icon-phone f_16 cCCC paddingR10 stringBug1"></i>'+val.phone+'</div>\
                                        </div>\
                                        <div class="f_18  c999 row-fluid">\
                                            <div class="span5 stringBug5">'+$app.delSecond(val.accessTime)+'</div>\
                                            <div class="span7  ">\
                                                <div class="oneIn oneIn_1"><i class="icon-office f_16 cCCC paddingR10 stringBug1"></i>'+(val.unit||' - ')+'</div>\
                                            </div>\
                                        </div>\
                                    </div>\
                                    <div class="span2">\
                                        <div class="f_20 text-right" style="padding-top:15px; color: '+ color +'\">'+label+'</div>\
                                    </div>\
                                </div>\
                            </div>\
                        </li>\
                        <li class="nothingDo"></li>';
                    });
    
                    $("#_3_thelist").append(htmlY);//节点插入
    
                });
                
            });
        }
    
        
        accessList3();//首次执行
    
    
    
        function pullUpActionDemo3(refreshCallback) {
            setTimeout(function () {
                accessList3();
                refreshCallback && refreshCallback();
            }, 300);
        }
        //搜索
        $('#_3_searchGo').on('click',function(){
            var keyword=$app.inputVal('#_3_topText');
            $app.setSession(keyword,'keyword');
            ui.refresh();
        });
    
    
        //跳转详情
        $('#_3_thelist').on('tap','li',function(){
            var id=$(this).attr('data-id');
            ui.load({
                url: '_2_detail.html',
                params: { id:id }
            });
        });
    };
    
})(window)